 package com.sinven.service;
 
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sinven.dao.CommentDao;
import com.sinven.mapper.CommentMapper;
import com.sinven.pojo.Comment;

@Service
public class CommentServiceImpl implements CommentService{
	//这个注解就是spring可以自动帮你把bean里面引用的对象的setter/getter方法省略
		@Autowired
			private CommentMapper commentMapper;
		private CommentDao commentDao;
		
		//重写	
	@Override
	/**
	 * 增加评论
	 */
	public boolean addComment(Comment comment) throws Exception {
		int count = commentMapper.addComment(comment);
		if(count>0) {
			return true;
		}
		return false;
	}

	@Override
	/**
	 * 删除评论
	 */
	public boolean deleteComment(int cid) throws Exception {
		int count = commentMapper.deleteComment(cid);
		if(count>0) {
			return true;
		}
		return false;
	}

	@Override
	/**
	 * 修改评论
	 */
	public boolean updateComment(int cid) throws Exception {
		int count = commentMapper.updateComment(cid);
		if(count>0) {
			return true;
		}
		return false;
	}

	@Override
	/**
	 * 查询评论数
	 *评论人查
	 */
	public int SelectAllCommentBySelf(int cid) throws Exception {
		int count =commentMapper.SelectAllCommentBySelf(cid);
		
		return count;
	}

	@Override
	/**
	 * 查询所有评论
	 */
	public List<Comment> SelectComentCountBySelf(int c_aId) throws Exception {
		List<Comment> list=commentMapper.SelectComentCountBySelf(c_aId);
		if(list==null) {
			return null;
		}
		return list;
	}

	@Override
	/**
	 * 按照条件查询所有
	 */
	public int SelectCommentByArticle(int c_aId) throws Exception {
		int count= commentMapper.SelectCommentByArticle(c_aId);
		
		return count;
	}

	@Override
	/**
	 * 查询一条评论
	 */
	public Comment SelectOneComment(int cid) throws Exception {
		Comment comment= commentMapper.SelectOneComment(cid);
		return comment;
	}

	@Override
	public List<Comment> findUsers() throws Exception {
		  List<Comment> list = commentDao.findUsers();
	        return list;
	}

	@Override
	public List<Comment> findUsersByPage(int start, int perPageUsers) throws Exception {
		 List<Comment> list = commentDao.findUsersByPage(start, perPageUsers);
	        return list;
	}

	
	
	
	


	 
	
}



